<template>
  <div>
    <p class="title">歌单列表</p>
    <van-cell
      center
      :title="item.name"
      :label="item.ar[0].name + '-' + item.name"
      v-for="item in list"
      :key="item.id"
    >
      <template #right-icon>
        <!-- <van-icon name="add-o" size="0.6rem" class="icon-shanchu_o" /> -->
        <span class="iconfont icon-shanchu_o" @click="del(item.id)"></span>
        <van-icon name="play-circle-o" size="0.6rem" @click="play(item.id)" />
      </template>
    </van-cell>
    <div class="empty" v-if="list.length === 0">
      <img src="../../assets/img/empty2.png" alt="" />
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      list: JSON.parse(localStorage.getItem('Glist') || '[]'),
      id: this.$store.state.timeId
    }
  },
  methods: {
    play (a) {
      console.log(a);
      this.$store.commit('setId', a)
      this.$store.commit('setPlayNum')
    },
    del (id) {
      console.log(1);
      this.$store.commit('del', id)
      this.list = this.list.filter(item => item.id != parseInt(id))
    }
  },
  created () {
    this.bus.$on('A', () => {
      this.list = JSON.parse(localStorage.getItem('Glist') || '[]')
    });
    console.log(this.list);
  },


}
</script>

<style scoped lang="less">
.icon-shanchu_o {
  margin-right: 20px;
  font-size: 25px;
}
.empty {
  width: 100%;
  height: auto;
  img {
    width: 100%;
    height: 13.75rem;
  }
}
.title {
  padding: 0.266667rem 0.24rem;
  margin: 0 0 0.24rem 0;
  background-color: #eee;
  color: #333;
  font-size: 15px;
}
/* 推荐歌单 - 歌名 */
.song_name {
  font-size: 0.346667rem;
  padding: 0 0.08rem;
  margin-bottom: 0.266667rem;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
  -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  -webkit-line-clamp: 2; /** 显示的行数 **/
  overflow: hidden; /** 隐藏超出的内容 **/
}
</style>
